home *** CD-ROM | disk | FTP | other *** search
- Path: news.voicenet.com!news
- From: kobak@voicenet.com (Peter Kobak)
- Newsgroups: comp.lang.c++
- Subject: Re: meaning of int a::*b
- Date: 22 Feb 1996 16:01:23 GMT
- Organization: Voicenet - Internet Access - (215)674-9290
- Message-ID: <4gi40j$kou@news.voicenet.com>
- NNTP-Posting-Host: ivyland243.voicenet.com
- X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
-
- In message <31284007.7977@mercury.co.il> - Shlomo Wygodny
- <wygodny@mercury.co.il> writes:
- :>
- :>In the following (compilable) program:
- :>
- :>class a{};
- :>int a::*b;
- :>void main(){}
- :>
- :>Does someone know what is the meaning of int a::*b; ?
- :>It's probably a declaration of a variable b of type int a::* .
- :>But what
- :>does it mean? What can be assigned to it?
- :>
- :>- Shlomo.
-
- I tried to post your question in .moderated, but it got rejected for being
- trivial. Well, it was new to me; I've seen pointers to member functions, but
- not member data. The .moderated moderator was kind enough to provide an
- explanation which follows:
-
- {This declares 'b' to be a "pointer to an 'int' member of 'a'". A
- suitable assignment would be something like:
- class a { public: int bar; };
- int a::*b = &a::bar;
- and a corresponding use would be
- a aobj;
- aobj.*b = 17; // assignment
- int dummy = aobj.*b; // access
- Using pointer-to-member you can make the member which is to be accessed
- modifyable. -mod}
-
- ================
- Peter Kobak
- kobak@voicenet.com
-
-
-